<?php


namespace app\data\model;


use think\admin\Model;

class DataCat extends Model
{
    function getList($map=[],$limit=20){
        $res = $this->alias('c')->field('c.*,b.breed_name,g.gender_name')
            ->join('data_breed b','b.id = c.breed')
            ->join('data_gender g','g.id = c.gender')
            ->filter(function($item) {
                $item['state'] = 0;
                return $item;
            })->where($map)
            ->where(['c.is_deleted'=>0])->limit($limit)->select()->toArray();
        return $res;
    }
    //更新宠物体重
    function updateWeight($cat_id,$weight){
       return $this->where(['id'=>$cat_id])->update(['weight'=>$weight]);
    }
}
